home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DBVGAL17.ARJ / DEMOS.ARJ / TEST.C < prev    next >
Text File  |  1992-01-26  |  4KB  |  124 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. #include "vidlib.h"
  6.  
  7. /**********************************************************************/
  8. /*                                                                    */
  9. /*  Test: The point, of course, is to thoroughly test functions that  */
  10. /*        weren't tested elsewhere. Total Quality, and all that.      */
  11. /**********************************************************************/
  12.  
  13. void main(void)
  14. {
  15.    int temp,i;
  16.  
  17.    printf("\n\nLow level function test for VIDLIB v%s\n\n", VIDLIB_VERSION);
  18.    /************************************************************/
  19.    printf("Exercising MO register functions.\n"
  20.           "Your screen may temporarily lose sync. Don't be alarmed.\n");
  21.  
  22.    temp=MOread_reg();
  23.    printf("MOread_reg()=%02x\n", temp);
  24.    getch();
  25.    MOset_regm(0x04,0x02);   /* disable display ram access */
  26.    printf("This line should NOT be displayed.\n");
  27.    getch();
  28.    MOset_reg(temp);
  29.    getch();
  30.    printf("If the last printed line reads 'MOread_reg() ...', then"
  31.           " MOset_regm() passes.\n");
  32.    printf("MOset_reg(%02x)=%02x\n", temp, MOread_reg());
  33.    if ( MOread_reg() == temp )
  34.       printf("MOread_reg() and MOset_reg() pass.\n");
  35.    else
  36.       printf("MOread_reg() and/or MOset_reg() fail.\n");
  37.    getch();
  38.  
  39.    /************************************************************/
  40.    printf("Waiting for vertical retrace.\n");
  41.    Vwait_vretrace();
  42.    printf("Waiting again for vertical retrace.\n");
  43.    Vwait_vretrace();
  44.    printf("Waiting for horizontal retrace.\n");
  45.    Vwait_hretrace();
  46.    printf("Waiting again for horizontal retrace.\n");
  47.    Vwait_hretrace();
  48.  
  49.    /************************************************************/
  50.    printf("\nExercising CRTC register functions.\n");
  51.  
  52.    CRTCset_reg(0x0d, 0x50);
  53.    if ( CRTCread_reg(0x0d) != 0x50)
  54.       printf("first set/read failed.\n");
  55.    else
  56.       printf("first set/read succeeded. Should've dropped 1 line.\n");
  57.    getch();
  58.    CRTCset_regm(0x0d, 0xf0, 0xaf);
  59.    if ( CRTCread_reg(0x0d) != 0xf0)
  60.       printf("second set/read failed.\n");
  61.    else
  62.       printf("second set/read succeeded. Should've dropped 2 more lines.\n");
  63.    getch();
  64.    CRTCset_reg(0x0d,0);
  65.    printf("Should've regained all lost lines.\n");
  66.    getch();
  67.  
  68.    /************************************************************/
  69.    printf("\nExercising GC register functions.\n");
  70.  
  71.    printf("GCread_reg(1)=%02x.\n", GCread_reg(1)); /* clock mode register */
  72.    temp=GCread_reg(2); /* plane enable register */
  73.    GCset_reg(2, 0x02);
  74.    if ( GCread_reg(2) == 0x02 )
  75.       printf("GCread_reg() and GCset_reg() pass.\n");
  76.    else
  77.       printf("GCread_reg() and/or GCset_reg() fail.\n");
  78.    GCset_regm(2, 0x0f, 0x01);
  79.    if ( GCread_reg(2) == 0x03 )
  80.       printf("GCset_regm() passes.\n");
  81.    else
  82.       printf("GCset_regm() fails, reg(2)=%02x.\n", GCread_reg(2));
  83.    GCset_reg(2, temp);
  84.    getch();
  85.  
  86.    /************************************************************/
  87.    printf("\nExercising AC register functions.\n");
  88.    temp=ACread_reg(0x12); /* color plane enable register
  89.                              caveat: bits 4-7 are status bits which can
  90.                              change at any time */
  91.    ACset_reg(0x12, 0x04);
  92.    if ( (ACread_reg(0x12) & 0x0f) == 0x04 )
  93.       printf("ACread_reg() and ACset_reg() pass.\n");
  94.    else
  95.       printf("ACread_reg() and/or ACset_reg() fail, reg(0x12)=%02x.\n",
  96.                            ACread_reg(0x12));
  97.    getch();
  98.    ACset_regm(0x12, 0x0f, 0x01);
  99.    if ( (ACread_reg(0x12) & 0x0f) == 0x05 )
  100.       printf("ACset_regm() passes.\n");
  101.    else
  102.       printf("ACset_regm() fails, reg(0x12)=%02x.\n",
  103.                            ACread_reg(0x12));
  104.    getch();
  105.    ACset_reg(0x12, temp);
  106.    printf("Testing horizontal panning with vertical retrace timing.\n");
  107.    for (i=0; i<2000; i++) {
  108.       Vwait_vretrace();
  109.       if ( i%9 == 0 ) {
  110.          CRTCset_reg(0x0d, CRTCread_reg(0x0d)+1);
  111.       }
  112.       ACset_regm(0x13, (i%9)-1 , 0x0f);
  113.       if (kbhit()) {
  114.          getch();
  115.          break;
  116.       }
  117.    }
  118.    ACset_reg(0x13,0xff);
  119.    CRTCset_reg(0x0d,0);
  120.  
  121.  
  122.    printf("\n\nTesting completed.\n\n");
  123.    exit(0);
  124. }